# users/signals.py

from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import EmailVerification
from datetime import timedelta

@receiver(post_save, sender=EmailVerification)
def set_expires_at(sender, instance, created, **kwargs):
    if created and not instance.expires_at:
        instance.expires_at = instance.created_at + timedelta(minutes=10)
        instance.save(update_fields=['expires_at'])
